<template>
  <div>
    <div class="navbar">
      <span class="navbar-title">AWK</span>
      <button class="navbar-login-btn" @click="goAdmin">进入后台</button>
    </div>
    <div class="home-bg"></div>
    <div class="wrapper-center">
      <div class="center-box">
        <div class="clock">{{ time }}</div>
        <form class="search-box" @submit.prevent="searchBaidu">
          <input
            v-model="query"
            type="text"
            placeholder="百度一下..."
            class="search-input"
          />
          <button type="submit" class="search-btn">搜索</button>
        </form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Home',
  data() {
    return {
      time: '',
      query: ''
    }
  },
  mounted() {
    this.updateTime();
    this.timer = setInterval(this.updateTime, 1000);
  },
  beforeUnmount() {
    clearInterval(this.timer);
  },
  methods: {
    updateTime() {
      const now = new Date();
      // 北京时间 = UTC+8
      const utc = now.getTime() + now.getTimezoneOffset() * 60000;
      const beijing = new Date(utc + 8 * 3600000);
      const y = beijing.getFullYear();
      const m = String(beijing.getMonth() + 1).padStart(2, '0');
      const d = String(beijing.getDate()).padStart(2, '0');
      const h = String(beijing.getHours()).padStart(2, '0');
      const min = String(beijing.getMinutes()).padStart(2, '0');
      const s = String(beijing.getSeconds()).padStart(2, '0');
      this.time = `${y}年${m}月${d}日 ${h}:${min}:${s}`;
    },
    searchBaidu() {
      if (!this.query.trim()) return;
      const url = `https://www.baidu.com/s?wd=${encodeURIComponent(this.query)}`;
      window.open(url, '_blank');
    },
    goAdmin() {
      this.$router.push('/admin');
    }
  }
}
</script>

<style scoped>
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 8px rgba(60,60,60,0.08);
  z-index: 10;
  backdrop-filter: blur(8px);
}
.navbar-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #007AFF;
  margin-left: 32px;
  letter-spacing: 2px;
  text-shadow: 0 2px 8px rgba(0,122,255,0.10);
}
.navbar-login-btn {
  margin-right: 32px;
  padding: 8px 28px;
  background: #007AFF;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,122,255,0.08);
  transition: background 0.2s;
}
.navbar-login-btn:hover {
  background: #0051A8;
}
.home-bg {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: url('@/assets/beijing.jpg') center center/cover no-repeat;
  background-size: cover;
  background-attachment: fixed;
  z-index: -1;
}

.wrapper-center {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  padding-top: 60px;
  box-sizing: border-box;
}

.center-box {
  width: 100%;
  max-width: 600px;
  background: rgba(255,255,255,0.18);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,122,255,0.10);
  padding: 48px 32px 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(6px);
}
.clock {
  font-size: 2.2rem;
  font-weight: 700;
  color: #007AFF;
  text-shadow: 0 2px 8px rgba(0,122,255,0.10);
  margin-bottom: 36px;
  letter-spacing: 2px;
  animation: clock-bounce 1s infinite alternate;
}
@keyframes clock-bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-8px); }
}
.search-box {
  width: 100%;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.85);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,122,255,0.08);
  padding: 6px 8px;
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1.15rem;
  padding: 12px 14px;
  border-radius: 8px;
  background: transparent;
  color: #222;
}
.search-btn {
  margin-left: 8px;
  padding: 10px 22px;
  background: #007AFF;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 8px rgba(0,122,255,0.08);
}
.search-btn:hover {
  background: #0051A8;
}
</style>

<style>
html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow-x: hidden;
}
</style> 